// Copyright (c) Microsoft Corporation.  All rights reserved.

#include "stdafx.h"
#include "D3D11ClassInstance.h"

#include "D3D11ClassLinkage.h"
using namespace Microsoft::WindowsAPICodePack::DirectX::Direct3D11;

ClassLinkage^ ClassInstance::GetClassLinkage()
{
    ID3D11ClassLinkage* tempoutLinkage = NULL;
    GetInterface<ID3D11ClassInstance>()->GetClassLinkage(&tempoutLinkage);

    return tempoutLinkage == NULL ? nullptr : gcnew ClassLinkage(tempoutLinkage);
}

ClassInstanceDescription^ ClassInstance::GetDescription()
{
    ClassInstanceDescription^ desc = gcnew ClassInstanceDescription();
    GetInterface<ID3D11ClassInstance>()->GetDesc(desc->nativeObject.Get());

    return desc;
}

String^ ClassInstance::GetInstanceName()
{
    SIZE_T len = CommonUtils::MaxNameSize;
    LPSTR tempInstanceName = new char[CommonUtils::MaxNameSize];

    GetInterface<ID3D11ClassInstance>()->GetInstanceName(tempInstanceName, &len);

    String^ name = gcnew String(tempInstanceName);
    delete [] tempInstanceName;

    return name;
}

String^ ClassInstance::GetTypeName()
{
    SIZE_T len = CommonUtils::MaxNameSize;
    LPSTR tempTypeName = new char[CommonUtils::MaxNameSize];

    GetInterface<ID3D11ClassInstance>()->GetInstanceName(tempTypeName, &len);

    String^ name = gcnew String(tempTypeName);
    delete [] tempTypeName;

    return name;
}

